<script setup>
import {exApi} from '@/api/quality/review'
import { QuillEditor } from '@vueup/vue-quill'
import { ref,getCurrentInstance, onMounted } from 'vue'

// 定义表单对象
const userForm = ref({
  review:'',
  result:1,
  reason:'',
})


// 表单引用
const formRef = ref()
// 弹出框定义
const dialogVisible = ref(false)
const show = (val)=>{
  dialogVisible.value = (val)
}
const handleClose = ()=>{
  dialogVisible.value = false 
}
const instance = getCurrentInstance()
// 新增清空表单方法
const resetForm = () => {
  userForm.value = {
  review:'',
  result:1,
  reason:'',
  }}

  // 修改审核
const editSubmit = async() => {
  let result = await exApi(userForm.value)
  dialogVisible.value = false
  // 通知父组件
  instance.emit('search')
}

// 暴露方法
defineExpose({
 dialogVisible,
  show,
  userForm,
  resetForm
})

</script>

<template>
  <el-dialog
    v-model="dialogVisible"
    title=""
    width="1200px"
    :before-close="handleClose"
  >
  <!-- 修改表单 -->
   <el-form 
      ref="formRef"
      :model="userForm" 
      :rules="rules"
      label-width="auto" 
      style="max-width: 1200px"
    >
    <el-row :gutter="10">
      <el-col :span="12">
        <!-- 添加 prop 属性 -->

          <el-form-item label="审核员">
          <el-input v-model="userForm.review" />
        </el-form-item>

      </el-col>
      <el-col :span="12">
        <!-- 添加 prop 属性 -->
        <el-form-item label="结果">
          <el-select v-model="userForm.result" placeholder="结果">
        <el-option label="NG" value="1" />
        <el-option label="OK" value="2" />
      </el-select>
        </el-form-item>
      </el-col>
       <el-col :span="24">
<el-form-item label="审核备注">
  <el-input 
    v-model="userForm.reason" 
    type="textarea" 
    :rows="6"
    style="width: 100%;"
    placeholder="请输入审核备注"
  />
</el-form-item>
</el-col>

     
    </el-row>
    <el-form-item>
      <el-button type="primary" @click="editSubmit">保存</el-button>
      <el-button @click="dialogVisible=false">取消</el-button>
    </el-form-item>
   </el-form>
  </el-dialog>
</template>